cmake_minimum_required(VERSION 3.15)

project(project3)

#bin 目录下保存最后生成的可执行文件
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/BIN")
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/BIN")

#将源码文件.cpp保存在SOURCE_DIR变量
# 收集源文件
aux_source_directory(src SOURCE_DIR)
#aux_source_directory(lib CANARD_SOURCES)  # 添加 lib 目录下的所有源码
#aux_source_directory(lib/uavcan UAVCAN_SOURCES)  # 添加 uavcan 消息相关源码

#指定头文件路径
include_directories(include)
include_directories(include/uavcan)
include_directories(include/canard)

# 收集源文件
file(GLOB_RECURSE CANARD_SRC "${PROJECT_SOURCE_DIR}/lib/*.c")
file(GLOB_RECURSE UAVCAN_ESC_SRC "${PROJECT_SOURCE_DIR}/lib/uavcan/*.c")


# 创建库
add_library(canard_lib ${CANARD_SRC})
add_library(uavcan_esc_lib ${UAVCAN_ESC_SRC})





add_definitions(-DDRONECAN_CXX_WRAPPERS)

# 构建可执行文件，包含所有源文件
add_executable(esc_node ${SOURCE_DIR} ${CANARD_SOURCES} ${UAVCAN_SOURCES})

# 链接所有库
target_link_libraries(esc_node PRIVATE
    canard_lib
    # socketcan_lib
    uavcan_esc_lib
    pthread
)